package demo2;

import java.util.LinkedList;
import java.util.List;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    //杨辉三角
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> list = new LinkedList<>();
        int[][] array = new int[numRows][];
        for (int i = 0; i < numRows; i++) {
            List<Integer> list1 = new LinkedList<>();
            for (int j = 0; j <= i; j++) {
                if (i == 1 || j == 1 || j == i) {
                    array[i][j] = 1;
                    list1.add(1);
                }else {
                    array[i][j] = array[i-1][j] + array[i-1][j-1];
                    list1.add(array[i-1][j] + array[i-1][j-1]);
                }
            }
            list.add(list1);
        }
        return list;
    }
}
